package com.bdqn.bookshop.controller.admin;

import com.bdqn.bookshop.entity.Setting;
import com.bdqn.bookshop.service.SettingService;
import com.bdqn.bookshop.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author : 罗若然[LUO_RUO_RAN]
 * @date : 2020-07-27 12:51
 **/
@RestController
@RequestMapping("/admin/setting")
public class AdminSettingController {

    @Autowired
    private SettingService settingService;

    @PostMapping("/uploadImage")
    public Map<String,Object> uploadImage(MultipartFile file, HttpServletRequest request){
        return settingService.uploadImage(file,request);
    }

    @PostMapping("/updateSetting")
    public Result updateSetting(@RequestParam(name="upload",required=false)MultipartFile file, Setting setting, HttpServletRequest request){
        return settingService.updateSetting(file,setting,request);
    }

}
